#{extends 'home.html' /}
<h1 class="viewTitle">User Profile</h1>

<div class="viewContent">
	#{if session.get("username") == null}
		<p>You must be logged in in order to be able to view your user profile.</p>
		<br></br>
	
	<a href = "@{Secure.login()}">Login now</a>
	<a href = "@{Users.register()}">New user? register now!</a>
	#{/if}
	
	
	#{else}
		#{if user == null}
			<p>The user you were looking for does not exist.</p>
		#{/if}
		#{else}
		
	<div id = "profilePicture">
#{if user.getPictureId() == -1}
<img src = "/public/images/missing.png" width="150px" height="150px" />
#{/if}
#{else}
<img src="@{Application.getPicture(user.id)}" width="150px" height="150px"/>
#{/else}
</div>


<style type="text/css">
#profilePicture{
position: relative;
bottom: 85px;
left:550px;
}
#info{
position:relative;
bottom: 100px;
}

</style>
		     <div id="info"> 
				<h2>Personal Information</h3>
				
				<table style="width:600px">
					
				  #{if showName}
				  <tr>
				    <td>Name:</th>
				    <td>${user.name}</th>
				  </tr>
				  #{/if}
				  
				  <tr>
				    <td>Username:</th>
				    <td>${user.userName}</th>
				  </tr>
				  
				  #{if showEmail}
				  <tr>
				    <td>Email:</td>
				    <td><a href="mailto:${user.email}">${user.email}</a></td>
				  </tr>
				  #{/if}
				  
				  <tr>
				    <td>Gender:</td>
				    <td>${user.gender}</td>
				  </tr>
				  
				  #{if showDOB}
				  <tr>
				    <td>Date of birth:</td>
				    <td>${user.dateOfBirth.getYear()+1900}-${user.dateOfBirth.getMonth()+1}-${user.dateOfBirth.getDate()}</td>
				  </tr>
				  #{/if}
				  
				  #{if showAddress}
				  <tr>
				    <td>Address:</td>
				    <td>${user.address}</td>
				  </tr>
				  #{/if}
				</table>
				
				<br>
				#{if session.get("username").equals(user.userName)}
						<a href="@{Users.editUserProfile()}" class="standardLink">Edit User Profile</a>
					#{if highPosition}
						<a href="@{ProfileController.myMergeRequests()}" class="standardLink">Merge Requests</a>
					#{/if}
					#{if isSystemAdmin}
					#{form @Users.adminCreateUser()}
						<div class="formEntry">
						 <br/>
						 <input type = "submit" value = "Create User"/></input>
						 <div class="clear"></div>
			             </div>					
					#{/form}
					#{form @Users.chooseDeletedUser()}
				    	<div class="formEntry">
						 <input type = "submit" value = "Delete User"/></input>
						 <div class="clear"></div>
			             </div>	
			        #{/form}
					#{form @Users.adminEditProfile()}
						<div class="formEntry">
						 <input type = "submit" value = "Edit User"/></input>
						 <div class="clear"></div>
			             </div>	
			        #{/form}
					#{/if}
				#{/if}
		#{/else}
	#{/else}
	#{if session.get("username") !=null}
#{if session.get("username").equals(user.userName)} 
<a id="changePic" href="@{Users.changeProfilePicture(user.id)}" class="standardLink">change profile picture</a>
#{/if}
#{/if}
</div>
</div>


<style type="text/css">
	#profilePicture{
		border-style: groove;
	border-color: navy;
	border-width:10px;
	-moz-border-radius: 10px;
  	-webkit-border-radius: 10px;  
  	border-radius: 10px;
  	width: 150px;
  	height: 150px;
	}
</style>	